using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PassiveReload:Upgrade {

	protected override void SubscribeEvents() {
		base.SubscribeEvents();
		MobEventHelper.updateStat.SubscribeSingle(weapon.owner,MobUpdate);
	}

	const float timeToReload = 10f;

	float timeAfterDeactivated;
	void MobUpdate(object _,object __) {
		timeAfterDeactivated+=deltaTime;
		if(weapon.isActiveAndEnabled) timeAfterDeactivated=0;
		if(weaponWeapon.currentClip.content.Count>=weaponWeapon.currentClip.clipSize) timeAfterDeactivated=0;
		if(timeAfterDeactivated>timeToReload) {
			timeAfterDeactivated=0;
			weaponWeapon.Reload();
		}
		string nameLast = weapon.gameObject.name;
		nameLast=new string(new char[1] { nameLast[nameLast.Length-1] });
		AddProgression(timeAfterDeactivated/timeToReload,nameLast,clamp0:true);
	}

}